///<reference path="../typings/index.d.ts"/>
import reqeust = require("request");

export class TestRequest {
    private socialReqeustUrl: string = "http://192.168.0.249:9918/api/Request/Action?RequestType=14";
    private tradeReqeustUrl: string = "http://192.168.0.249:9918/api/Request/Action?RequestType=143";
    start() {

        for (var i = 0; i < 200; i++) {
            this.requestSocial();
        }
    }
    startTime() {

        setInterval(() => { this.start() }, 3000);
    }
    startTimerForRequestSuning() {
        setInterval(() => { this.requestLagou() }, 100);
    }
    requestSocial() {

        reqeust.post(this.tradeReqeustUrl, { headers: { 'Content-Type': 'application/json' }, body: '{"RequestData":{"BrokerID":0,"DirectionType":1,"PageIndex":0,"PageSize":15,"RankType":4,"SortType":11,"TimeRange":7,"TraderNickName":""},"From":32230,"RequestType":143,"UserID":"121015"}' }, (err, response, body) => {
            console.log("done");
        });
    }
    requestSuningYigou(): void {
        console.log("now reuqest url");
        const url = "https://detail.tmall.com/item.htm?id=560196706618&pid=mm_25282911_3455987_122436732&sku_properties=10004:709990523;5919063:6536025;12304035:3222911";
        console.log("request suning url");
        reqeust(url, (err, body, content) => {
            if (err) {
                console.log("request suning yi gou  error" + err);
                return;
            }
            console.log(content);
        });
    }
    requestLagou(): void {
        const url = "https://activity.lagou.com/activityapi/employer/signUp?companyId=115637";
         
        reqeust(url, (err, body, content) => {
            if (err) {
                console.log("reqeust lagou error:"+ err);
                return;
            }
           // console.log(body);
            console.log(content);
        });
    }
}
console.log("now begin service ");
new TestRequest().startTimerForRequestSuning();